﻿using System;
using System.Net;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
#if SILVERLIGHT
using System.Windows.Browser;
#endif

namespace SMS.Entities.BaseClasses
{
    public class BaseNotify : INotifyPropertyChanged
    {
        public BaseNotify()
        {
            
        }
        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string PropertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
        }

        protected virtual void ShowMessage(string message)
        {
            #if SILVERLIGHT
            HtmlPage.Window.Alert(message);
            #endif
        }

        protected virtual void ShowError(string error)
        {
            ShowMessage(error);
        }

        #region "Property For ErrorControl"
        private string _UserMessage;

        public string UserMessage
        {
            get { return _UserMessage; }
            set { _UserMessage = value; OnPropertyChanged("UserMessage"); _ErrorMessage = string.Empty; OnPropertyChanged("ErrorMessage"); }
        }

        private string _ErrorMessage;

        public string ErrorMessage
        {
            get { return _ErrorMessage; }
            set { _ErrorMessage = value; OnPropertyChanged("ErrorMessage"); _UserMessage = string.Empty; OnPropertyChanged("UserMessage"); }
        }
        #endregion        
    }
}
